Not sure what to call this. Updating variable?

by: rbowles28, 7 years ago

Last edited: 7 years ago

I would love for you to do a tutorial on this. How to trigger events and do math with an updating variable.
I'm building an iracing app that triggers multiple events when I complete a lap. The laps count up every time I pass the start/finish line. When this happens, I need to save my current fuel load to a database or csv. Then subtract the last lap fuel from the current lap. I have another app where a json updates approx. every hour, so I check over and over until the time changes which triggers a download.  I accomplish this by saving two different variables. A static and a loop looking for the change. When they aren't the same that triggers the event. I'm just wondering if there is a standard way or module to do this?

def timeStamp(self):
        pre_open = WowApi.get_auctions()
        get_time = str(pre_open['files'][0]['lastModified'])
        updated_time = get_time
        while True:
            get_loop_time = WowApi.get_auctions()
            updated_time = str(get_loop_time['files'][0]['lastModified'])
            trim_time = ((updated_time[0:-3]))
            format_time = datetime.fromtimestamp(int(trim_time)).strftime('%m-%d-%Y %I:%M %p')
            self.time_stamp.emit("Last Update: " + str(format_time))
            time.sleep(10)
            if get_time != updated_time:
                self.auctionDownloadUrl()
                self.auctionAlert()
                time.sleep(3640)
                self.timeStamp()




You must be logged in to post. Please login or register an account.